home *** CD-ROM | disk | FTP | other *** search
- on setVis flag
- repeat with X = 1 to the lastChannel
- sprite(X).visible = flag
- end repeat
- end
-
- on resetNewCharacterTimer
- global gLastCharacterArrived
- gLastCharacterArrived = now()
- end
-
- on timeSinceLastCharacter
- global gLastCharacterArrived
- return elapsedTime(gLastCharacterArrived)
- end
-
- on resetForcedCharacterTimer
- global gLastCharacterForced, gForceNextCharacterAt
- gLastCharacterForced = now()
- gForceNextCharacterAt = randomBetween(currentLevel(#newCharacterMinInterval), currentLevel(#newCharacterMaxInterval))
- end
-
- on timeSinceLastForcedCharacter
- global gLastCharacterForced
- return elapsedTime(gLastCharacterForced)
- end
-
- on newCharNoSoonerThan interval
- global gLastCharacterArrived
- return gLastCharacterArrived = (currentLevel(#newCharacterMinInterval) - interval)
- end
-
- on sumGameLevels thang, startLevel, endLevel
- global gGameSetup, gGameLevel
- sumIt = 0
- if voidp(startLevel) then
- startLevel = 1
- end if
- if voidp(endLevel) then
- endLevel = gGameLevel
- end if
- repeat with gameLevel = startLevel to endLevel
- sumIt = sumIt + gGameSetup[gameLevel][thang]
- end repeat
- return sumIt
- end
-
- on checkElapsedTime
- global gForceNextCharacterAt, gBarTopManager, gPauseState, gPlayerTips, gPearlyGates, gUserQuitFlag
- if gPauseState then
- exit
- else
- if inTestMode() then
- exit
- else
- if inBonusMode() then
- exit
- else
- if gPearlyGates then
- exit
- else
- if gUserQuitFlag then
- exit
- else
- if inMenuMode() then
- exit
- end if
- end if
- end if
- end if
- end if
- end if
- if not inRecipeMode() then
- if (timeSinceLastForcedCharacter() > gForceNextCharacterAt) or (numberAtBar(gBarTopManager) = 0) then
- if gPlayerTips = 0 then
- resetForcedCharacterTimer()
- else
- if newCharacterEnters(#ifServed) then
- resetForcedCharacterTimer()
- end if
- end if
- end if
- end if
- repeat with X = 1 to numBarSlots()
- sendSprite(barSlotToSprite(X), #timeElapsed)
- end repeat
- end
-
- on draggingBarTopGlass
- global gWellSprite
- if draggingWellThang() then
- if isGlassIngredient(gWellSprite.pIngredient) then
- return 1
- end if
- end if
- return 0
- end
-
- on draggingBottleThang
- global gDraggingBottle
- return gDraggingBottle
- end
-
- on draggingBottleOrSpoon
- return draggingBottleThang() or draggingSpoon()
- end
-
- on draggingAnything
- return draggingBottleThang() or draggingWellThang() or draggingSpoon()
- end
-
- on draggingIngredient
- return draggingBottleThang() or draggingWellThang()
- end
-
- on draggingSpoon
- global gSpoonSprite
- dragging = gSpoonSprite[#pDragging]
- if voidp(dragging) then
- return 0
- else
- return dragging
- end if
- end
-
- on draggingWellThang
- global gWellSprite
- return gWellSprite.visible and (gWellSprite.memberNum > 0)
- end
-
- on pourIt receiveSound
- global gDraggingBottle
- sendSprite(gDraggingBottle, #pour, sprite(gDraggingBottle).pIngredient, receiveSound)
- end
-
- on fillVessel me, ingredient, liquidColor
- if ingredient = #ice then
- stopSoundFX()
- message = sendSprite(me.pGlassIce, #mFillIce, me)
- else
- if isPowder(ingredient) then
- if calcPowder(me.pContents) > 0 then
- message = sendSprite(me.pGlassMask, #mFillLiquor, white(), me)
- end if
- else
- message = sendSprite(me.pGlassMask, #mFillLiquor, liquidColor, me)
- end if
- end if
- return message
- end
-
- on buildVesselContentList inSprite, vesselName, default
- pContents = inSprite.pContents
- pContentString = inSprite.pContentString
- if (pContentString = EMPTY) or voidp(pContentString) or (pContentString = default) then
- pContentString = EMPTY
- repeat with X = 1 to count(pContents)
- ingredient = getPropAt(pContents, X)
- cat = getCategory(ingredient)
- if ((cat >= 1) and (cat <= 9)) or (cat = 16) then
- if pContentString = EMPTY then
- if vesselName = #beer then
- vesselName = EMPTY
- else
- vesselName = getShortName(vesselName) && "Contents:" & RETURN
- end if
- pContentString = SPACE & vesselName
- end if
- addText = getDosage(ingredient, pContents[X], inSprite) & TAB & getMediumName(ingredient)
- pContentString = pContentString && addText & RETURN
- end if
- end repeat
- delete char -30000 of pContentString
- end if
- if (pContentString = EMPTY) or voidp(pContentString) then
- pContentString = default
- end if
- return pContentString
- end
-
- on numBarSlots
- global gBarTopManager
- return mGetNumBarSlots(gBarTopManager)
- end
-
- on testLabels
- global debug
- debug = 1
- go("testflash")
- repeat with X = 1 to 8
- getFlashLabels(script(35), X, 0)
- end repeat
- debug = 0
- end
-
- on clearRecipe barSlot, ensureWindow
- setRecipePatronName(barSlot, "No Patron")
- setRecipeDrinkName(barSlot, "No Drink")
- refreshRecipeWindow(ensureWindow)
- end
-
- on mergeColors foo
- rbuf = 0
- gbuf = 0
- bbuf = 0
- numCol = count(foo)
- if numCol = 0 then
- return rgb(0, 0, 0)
- end if
- repeat with i = 1 to numCol
- goo = foo[i]
- thisColor = goo[1]
- weight = goo[2]
- rbuf = rbuf + (weight * (255 - thisColor.red))
- gbuf = gbuf + (weight * (255 - thisColor.green))
- bbuf = bbuf + (weight * (255 - thisColor.blue))
- end repeat
- rbuf = 255 - float(rbuf)
- gbuf = 255 - float(gbuf)
- bbuf = 255 - float(bbuf)
- return rgb(rbuf, gbuf, bbuf)
- end
-
- on weightedRGBofLiquids pContents
- weightedList = []
- totalQuantity = calcLiquidContents(pContents)
- if totalQuantity = 0 then
- return []
- end if
- repeat with X = 1 to count(pContents)
- thisOne = getPropAt(pContents, X)
- cat = getCategory(thisOne)
- if getOne([2, 4, 5, 6, 7, 8, 16], cat) then
- add(weightedList, [getLiquidColor(thisOne), float(pContents[X]) / totalQuantity])
- end if
- end repeat
- return weightedList
- end
-
- on calcTheseContents pContents, catList
- global gTspPerOunce
- totalQuantity = 0
- repeat with X = 1 to count(pContents)
- thisOne = getPropAt(pContents, X)
- cat = getCategory(thisOne)
- if getOne(catList, cat) then
- if cat = 7 then
- totalQuantity = totalQuantity + (pContents[X] / gTspPerOunce)
- next repeat
- end if
- totalQuantity = totalQuantity + pContents[X]
- end if
- end repeat
- return max(0, totalQuantity)
- end
-
- on calcContents pContents
- return calcTheseContents(pContents, [1, 2, 3, 4, 5, 6, 8, 16]) + calcPowder(pContents)
- end
-
- on calcPowder pContents, tspToSubtract
- global gTspPerOunce
- powders = calcTheseContents(pContents, [7])
- if voidp(tspToSubtract) then
- tspToSubtract = 2.0
- end if
- return max(0, powders - (tspToSubtract / gTspPerOunce))
- end
-
- on calcEmpty pContents
- return calcTheseContents(pContents, [1, 2, 3, 4, 5, 6, 7, 8, 16]) = 0
- end
-
- on calcLiquidContents pContents
- return calcTheseContents(pContents, [2, 3, 4, 5, 6, 8, 16]) + calcPowder(pContents)
- end
-
- on calcPourableContents pContents
- pourable = calcTheseContents(pContents, [2, 3, 4, 5, 6, 8]) + calcPowder(pContents)
- if pourable > 0 then
- return pourable
- else
- if voidp(pContents[#Slush]) then
- return 0
- else
- return pContents[#Slush]
- end if
- end if
- end
-
- on countStirrableIngredients pContents
- return countIngredients(pContents, [1, 2, 3, 4, 5, 6, 7, 8, 16])
- end
-
- on countIngredients pContents, catList
- stirCount = 0
- repeat with X = 1 to count(pContents)
- thisOne = getPropAt(pContents, X)
- cat = getCategory(thisOne)
- if getOne(catList, cat) then
- stirCount = stirCount + 1
- end if
- end repeat
- return max(0, stirCount)
- end
-
- on calcLiquorContents pContents
- return calcTheseContents(pContents, [2, 6, 8]) + (calcTheseContents(pContents, [3]) * 2.0)
- end
-
- on calcWimpyContents pContents
- return calcTheseContents(pContents, [4, 5])
- end
-
- on addIce iceSprite, masterSprite, maxIceUnits, newMember, iceSound
- if iceSprite.pIceAmount = maxIceUnits then
- alertBeep()
- return 0
- else
- pIceToAdd = iceSprite.pIcePerScoop
- roomNeeded = mIsHoldingVolume(masterSprite) + pIceToAdd - masterSprite.pCapacity
- if roomNeeded > 0.001 then
- pIceToAdd = min(pIceToAdd, masterSprite.pCapacity - mIsHoldingVolume(masterSprite))
- end if
- end if
- if voidp(masterSprite.pContents[#ice]) then
- masterSprite.pContents[#ice] = pIceToAdd
- else
- masterSprite.pContents[#ice] = masterSprite.pContents[#ice] + pIceToAdd
- end if
- iceSprite.pIceAmount = iceSprite.pIceAmount + 1
- if not voidp(newMember) then
- iceSprite.member = newMember
- end if
- soundFX(iceSound, 1, 1)
- sendSprite(masterSprite.pGlassMask, #mUpdateLiquidLevel, masterSprite)
- return 1
- end
-
- on fillIt pSpr, liquidColor, maskMember, maskLimit, masterSprite
- global gPixelList
- capacity = masterSprite.pCapacity
- affectedByIce = masterSprite.pContents[#ice]
- if affectedByIce = VOID then
- affectedByIce = 0
- end if
- maskStart = masterSprite.pGlassMask.pMaskStart
- currentQuantity = sendSprite(masterSprite.spriteNum, #mIsHoldingLiquid)
- pContents = masterSprite.pContents
- if count(pContents) then
- if currentQuantity > 0 then
- sprite(masterSprite.pGlassMask).color = mergeColors(weightedRGBofLiquids(pContents))
- else
- sprite(masterSprite.pGlassMask).color = black()
- end if
- else
- if not voidp(liquidColor) then
- sprite(masterSprite.pGlassMask).color = liquidColor
- end if
- end if
- a = maskMember.regPoint
- X = a.locH
- pixelsPerOunce = gPixelList[masterSprite.pGlassType]
- if masterSprite.pGlassType = #cocktail then
- stuff = currentQuantity * 3.81999999999999984
- height = power(stuff, 1 / 3.0)
- if currentQuantity = 0 then
- pixelsPerOunce = 1
- else
- pixelsPerOunce = height / currentQuantity * 6.5
- end if
- end if
- if currentQuantity < affectedByIce then
- Y = maskStart + (currentQuantity * pixelsPerOunce * 2)
- else
- Y = maskStart + (affectedByIce * pixelsPerOunce * 2) + ((currentQuantity - affectedByIce) * pixelsPerOunce)
- end if
- if Y > maskLimit then
- maskMember.regPoint = point(X, maskLimit)
- return 0
- else
- maskMember.regPoint = point(X, Y)
- return 1
- end if
- end
-
- on forceRecipeSelection newRecipeID
- if inRecipeMode() then
- sendSprite(barSlotToSprite(2), #mForceRecipe, newRecipeID)
- end if
- end
-
- on togglePourClockText direction, onFlag
- global gDrinkContentSpr
- sendSprite(gDrinkContentSpr, #mRepositionSelf, direction, onFlag)
- end
-
- on setPourClockText tipText, Force
- global gDrinkContentSpr
- sendSprite(gDrinkContentSpr, #mShowDrinkContents, tipText, Force)
- end
-
- on formatBirthDate convertDate
- return "DOB:" && formatDate(convertDate)
- end
-
- on formatExpirationDate expDate
- if voidp(expDate) then
- expDate = randomDateInFuture()
- end if
- return "Expires:" && expDate
- end
-
- on randomDateInFuture
- today = systemDate()
- return formatDate(date(today.year + random(3), random(12), random(31)))
- end
-
- on formatDate convertDate
- month = string(convertDate.month)
- day = string(convertDate.day)
- year = convertDate.year
- century = year / 100
- if length(day) < 2 then
- put "0" before month
- end if
- if length(month) < 2 then
- put "0" before month
- end if
- year = year - (century * 100)
- year = string(year)
- if length(year) < 2 then
- put "0" before month
- end if
- return month & "/" & day & "/" & year
- end
-
- on checkAge inDate, birthDate, yearsOfAge
- myDate = inDate
- inYear = inDate.year
- if (inDate - birthDate) >= (date(inYear + yearsOfAge, 1, 1) - date(inYear, 1, 1)) then
- return 1
- else
- return 0
- end if
- end
-
- on diffFactor DIFFICULTY
- case DIFFICULTY of
- 1, 2:
- return currentLevel(#diffVlow)
- 3, 4:
- return currentLevel(#DIFFLOW)
- 5, 6:
- return currentLevel(#DIFFMED)
- 7, 8:
- return currentLevel(#DIFFHIGH)
- 9, 10:
- return currentLevel(#diffVHigh)
- end case
- end
-
- on glassPrefix glassType
- return string(glassType).char[1..3]
- end
-
- on checkIfFlashWasHit me, pSpr
- global gBarTopManager, gGaveIDcardHint, gGaveOrderHint, gGameLevel, gClickToIDorOrder
- if pSpr.member.type <> #flash then
- exit
- end if
- hitMe = hitTest(pSpr, the clickLoc)
- wasDragging = draggingAnything()
- if wasDragging and (the clickOn = me.spriteNum) then
- replaceDraggingAnything()
- end if
- if hitMe = #normal then
- if wasDragging then
- replaceDraggingAnything()
- end if
- if bouncingOrRetreating(me) then
- alertBeep()
- exit
- end if
- lastActiveSlot = getActiveSlot(gBarTopManager)
- if lastActiveSlot = me.pMyBarSlot then
- newActiveCharacter = 0
- else
- newActiveCharacter = 1
- makePatronActive(me.pMyBarSlot)
- end if
- if wasDragging then
- replaceDraggingAnything()
- else
- if modifierDown() and inTestMode() then
- characterLeft(me)
- else
- if not busy(me) then
- if gGameLevel = 1 then
- if not me.pAlreadyCarded then
- if not gGaveIDcardHint then
- remindAboutID()
- else
- if gClickToIDorOrder then
- card(me)
- end if
- end if
- else
- if me.pStatus = #carded then
- if not gGaveOrderHint then
- remindToTakeOrder()
- else
- if gClickToIDorOrder then
- order(me)
- end if
- end if
- end if
- end if
- end if
- if not newActiveCharacter then
- beckon(me)
- end if
- end if
- end if
- end if
- else
- if me.pMyBarSlot > 1 then
- sendSprite(barSlotToSprite(me.pMyBarSlot - 1), #mouseUp)
- end if
- end if
- end
-
- on floor input
- if input = 0 then
- return 0
- else
- if input > 0 then
- return integer(input - 0.5)
- else
- return integer(input + 0.5)
- end if
- end if
- end
-